import * as ActionTypes from '../../constants/ActionType';
const {
    SET_ADMIN_STATE,
    GET_ARTICLE_ADMIN
     } = ActionTypes;

const intialState = {
    articles: [],
}
export default function adminData(state = intialState, action) {
    const { type, payload } = action;
    switch (type) {
        case SET_ADMIN_STATE:
            return { ...state, ...payload };
        case GET_ARTICLE_ADMIN:
            const articles = payload.map((x) => { return { label: x.title, ...x } })
            return { ...state, articles };
        default:
            return state;
    }
}